package com.rjj.wlqq.wxpay.wxpay.entity;


import com.rjj.wlqq.wx.tool.StrKit;

/**
 * @author r
 * @date 2021/1/20 18:11
 * 微信申请退款
 * https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
 *
 * <xml>
 * <appid>wx2421b1c4370ec43b</appid>
 * <mch_id>10000100</mch_id>
 * <nonce_str>6cefdb308e1e2e8aabd48cf79e546a02</nonce_str>
 * <out_refund_no>1415701182</out_refund_no>
 * <out_trade_no>1415757673</out_trade_no>
 * <refund_fee>1</refund_fee>
 * <total_fee>1</total_fee>
 * <transaction_id>4006252001201705123297353072</transaction_id>
 * <sign>FE56DD4AA85C0EECA82C35595A69E153</sign>
 * </xml>
 */
public class OrderRefund
{
    private String transaction_id;
    private String out_trade_no;
    private String out_refund_no;
    private String total_fee;
    private String refund_fee;

    private String refund_desc;
    private String notify_url;

    OrderRefund(String transaction_id, String out_trade_no, String out_refund_no, String total_fee, String refund_fee, String refund_desc, String notify_url)
    {
        this.transaction_id = transaction_id;
        this.out_trade_no = out_trade_no;
        this.out_refund_no = out_refund_no;
        this.total_fee = total_fee;
        this.refund_fee = refund_fee;
        this.refund_desc = refund_desc;
        this.notify_url = notify_url;
    }

    public static OrderRefundBuilder builder()
    {
        return new OrderRefundBuilder();
    }


    public String getTransaction_id()
    {
        return this.transaction_id;
    }

    public String getOut_trade_no()
    {
        return this.out_trade_no;
    }

    public String getOut_refund_no()
    {
        return this.out_refund_no;
    }

    public String getTotal_fee()
    {
        return this.total_fee;
    }

    public String getRefund_fee()
    {
        return this.refund_fee;
    }

    public String getRefund_desc()
    {
        return this.refund_desc;
    }

    public String getNotify_url()
    {
        return this.notify_url;
    }

    public void setTransaction_id(String transaction_id)
    {
        this.transaction_id = transaction_id;
    }

    public void setOut_trade_no(String out_trade_no)
    {
        this.out_trade_no = out_trade_no;
    }

    public void setOut_refund_no(String out_refund_no)
    {
        this.out_refund_no = out_refund_no;
    }

    public void setTotal_fee(String total_fee)
    {
        this.total_fee = total_fee;
    }

    public void setRefund_fee(String refund_fee)
    {
        this.refund_fee = refund_fee;
    }

    public void setRefund_desc(String refund_desc)
    {
        this.refund_desc = refund_desc;
    }

    public void setNotify_url(String notify_url)
    {
        this.notify_url = notify_url;
    }


    @Override
    public String toString()
    {
        return "OrderRefund(transaction_id=" + this.getTransaction_id() + ", out_trade_no=" + this.getOut_trade_no() + ", out_refund_no=" + this.getOut_refund_no() + ", total_fee=" + this.getTotal_fee() + ", refund_fee=" + this.getRefund_fee() + ", refund_desc=" + this.getRefund_desc() + ", notify_url=" + this.getNotify_url() + ")";
    }

    public static class OrderRefundBuilder
    {
        private String transaction_id;
        private String out_trade_no;
        private String out_refund_no;
        private String total_fee;
        private String refund_fee;
        private String refund_desc;
        private String notify_url;

        OrderRefundBuilder()
        {
        }

        public OrderRefundBuilder transaction_id(String transaction_id)
        {
            this.transaction_id = transaction_id;
            return this;
        }

        public OrderRefundBuilder out_trade_no(String out_trade_no)
        {
            this.out_trade_no = out_trade_no;
            return this;
        }

        public OrderRefundBuilder out_refund_no(String out_refund_no)
        {
            this.out_refund_no = out_refund_no;
            return this;
        }

        public OrderRefundBuilder total_fee(String total_fee)
        {
            this.total_fee = total_fee;
            return this;
        }

        public OrderRefundBuilder refund_fee(String refund_fee)
        {
            this.refund_fee = refund_fee;
            return this;
        }

        public OrderRefundBuilder refund_desc(String refund_desc)
        {
            this.refund_desc = refund_desc;
            return this;
        }

        public OrderRefundBuilder notify_url(String notify_url)
        {
            this.notify_url = notify_url;
            return this;
        }

        public OrderRefund build()
        {
            if (StrKit.isBlank(this.transaction_id))
            {
                throw new IllegalStateException("transaction_id is null");
            } else if (StrKit.isBlank(this.total_fee))
            {
                throw new IllegalStateException("total_fee is null");
            } else if (StrKit.isBlank(this.refund_fee))
            {
                throw new IllegalStateException("refund_fee is null");
            } else if (StrKit.isBlank(this.out_refund_no))
            {
                throw new IllegalStateException("out_refund_no is null");
            } else if (StrKit.isBlank(this.out_trade_no))
            {
                throw new IllegalStateException("out_trade_no is null");
            } else
            {
                return new OrderRefund(transaction_id, out_trade_no, out_refund_no, total_fee, refund_fee, refund_desc, notify_url);
            }
        }

        @Override
        public String toString()
        {
            return "OrderRefund.OrderRefundBuilder(transaction_id=" + this.transaction_id + ", out_trade_no=" + this.out_trade_no + ", out_refund_no=" + this.out_refund_no + ", total_fee=" + this.total_fee + ", refund_fee=" + this.refund_fee + ", refund_desc=" + this.refund_desc + ", notify_url=" + this.notify_url + ")";
        }
    }
}
